﻿<UserControl x:Class="MediaAssistant.Controls.PlayerControl.PlayerControlView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:Converters="clr-namespace:MediaAssistant.Converters" 
             xmlns:Constants="clr-namespace:MediaAssistant.Constants" xmlns:DALConstants="clr-namespace:MediaAssistant.DAL.Constants;assembly=MediaAssistant.DAL" Width="Auto" Height="Auto" 
             Visibility="{Binding LibraryManager.CurrentViewType, Converter={StaticResource ViewTypeToVisibilityConverter}, ConverterParameter={x:Static DALConstants:LibraryItemType.MusicType}}">
	<UserControl.Resources>
    <Converters:BoolInverseConverter x:Key="BoolInverseConverter" />
    <Style x:Key="ShuffleModeButtonStyle" TargetType="Button">
      <Style.Triggers>
        <DataTrigger Binding="{Binding Path=DataSource.SelectedMusicDJ.Name}" Value="{x:Static Constants:MusicDJName.SmartDJ}">
          <DataTrigger.Setters>
            <Setter Property="Content" Value="{StaticResource SmartShuffleImage}"/>
            <Setter Property="ToolTip" Value="Play music based on preferance and mode"/>
          </DataTrigger.Setters>
        </DataTrigger>
        <DataTrigger Binding="{Binding Path=DataSource.SelectedMusicDJ.Name}" Value="{x:Static Constants:MusicDJName.RandomDJ}">
          <DataTrigger.Setters>
            <Setter Property="Content" Value="{StaticResource NormalShuffleImage}"/>
            <Setter Property="ToolTip" Value="Play music randomly"/>
          </DataTrigger.Setters>
        </DataTrigger>
        <DataTrigger Binding="{Binding Path=DataSource.SelectedMusicDJ.Name}" Value="{x:Static Constants:MusicDJName.SequentialDJ}">
          <DataTrigger.Setters>
            <Setter Property="Content" Value="{StaticResource NoShuffleImage}"/>
            <Setter Property="ToolTip" Value="Play music sequencially"/>
          </DataTrigger.Setters>
        </DataTrigger>
        <DataTrigger Binding="{Binding Path=DataSource.SelectedMusicDJ.Name}" Value="{x:Static Constants:MusicDJName.NoDJ}">
          <DataTrigger.Setters>
            <Setter Property="Content" Value="{StaticResource NoDJImage}"/>
            <Setter Property="ToolTip" Value="Turn off automatic music play"/>
          </DataTrigger.Setters>
        </DataTrigger>
      </Style.Triggers>
    </Style>
	</UserControl.Resources>
	<StackPanel Orientation="Horizontal" Margin="5,0">
        <Button Margin="3,0" Width="25" Height="25" Style="{StaticResource PreviousButtonStyle}" Command="{Binding PreviousMusicCommand}" IsEnabled="{Binding DataSource.SelectedMusicDJ.CanMovePrevious}" ToolTip="Previous" />
        <ToggleButton Margin="3,0" Width="30" Height="30" Style="{StaticResource PlayButtonStyle}" 
                      IsChecked="{Binding DataSource.IsPlaying}" 
                      IsEnabled="{Binding DataSource.CanPlay}" ToolTip="Play" />
        <Button Margin="3,0" Width="25" Height="25" Style="{StaticResource NextButtonStyle}" Command="{Binding NextMusicCommand}" IsEnabled="{Binding DataSource.SelectedMusicDJ.CanMoveNext}" ToolTip="Next" />
        <ToggleButton Margin="3,0" Content="{StaticResource MuteImage}" Width="25" Height="25" Style="{StaticResource toggleOptionButtonStyle}"
               IsChecked="{Binding DataSource.MusicPlayer.IsMuted}" ToolTip="Mute" />
        <Slider Margin="3,5,3,3" Orientation="Horizontal" Width="100" Height="25" VerticalAlignment="Center" Minimum="0" Maximum="1" Value="{Binding DataSource.MusicPlayer.Volume}" ToolTip="Volume" />
        <ToggleButton Margin="3,0" Content="{StaticResource VolumeImage}" Width="25" Height="25" Style="{StaticResource toggleOptionButtonStyle}"
                      IsChecked="{Binding DataSource.MusicPlayer.IsMuted, Converter={StaticResource BoolInverseConverter}}" ToolTip="Volume" />
        <Button Margin="3,0" Width="25" Height="25" Click="HandleToolButtonClocked" 
                Style="{StaticResource ShuffleModeButtonStyle}"
                Content="{StaticResource SmartShuffleImage}">
            <Button.ContextMenu>
                <ContextMenu Name="ShuffleMenu">
                    <MenuItem Header="{x:Static Constants:MusicDJName.SmartDJ}" 
                              IsChecked="{Binding DataSource.SelectedMusicDJ.Name, Converter={StaticResource ParameterEqualityConverter}, ConverterParameter={x:Static Constants:MusicDJName.SmartDJ}}" 
                              Command="{Binding ChangeShuffleModeCommand}" CommandParameter="{x:Static Constants:MusicDJName.SmartDJ}"/>
                    <MenuItem Header="{x:Static Constants:MusicDJName.RandomDJ}" 
                              IsChecked="{Binding DataSource.SelectedMusicDJ.Name, Converter={StaticResource ParameterEqualityConverter}, ConverterParameter={x:Static Constants:MusicDJName.RandomDJ}}" 
                              Command="{Binding ChangeShuffleModeCommand}" CommandParameter="{x:Static Constants:MusicDJName.RandomDJ}"/>
                    <MenuItem Header="{x:Static Constants:MusicDJName.SequentialDJ}" 
                              IsChecked="{Binding DataSource.SelectedMusicDJ.Name, Converter={StaticResource ParameterEqualityConverter}, ConverterParameter={x:Static Constants:MusicDJName.SequentialDJ}}" 
                              Command="{Binding ChangeShuffleModeCommand}" CommandParameter="{x:Static Constants:MusicDJName.SequentialDJ}"/>
                  <MenuItem Header="{x:Static Constants:MusicDJName.NoDJ}"
                              IsChecked="{Binding DataSource.SelectedMusicDJ.Name, Converter={StaticResource ParameterEqualityConverter}, ConverterParameter={x:Static Constants:MusicDJName.NoDJ}}"
                              Command="{Binding ChangeShuffleModeCommand}" CommandParameter="{x:Static Constants:MusicDJName.NoDJ}"/>
                </ContextMenu>
            </Button.ContextMenu>
      </Button>
    <ContentControl Content="{Binding DataSource.MusicPlayer}"/>
    </StackPanel>
</UserControl>
